home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / misc / emu / Apex-src.lha / BOOTA2.68K < prev    next >
Text File  |  2001-09-30  |  9KB  |  286 lines

  1. ;BOOTA2.68K    FEB-25-89
  2. ;Apex Bootstrap for the Amiga 2000 and 500 (use BOOTA.68K for the Amiga
  3. ; 1000).
  4. ;Written by Loren Blaney
  5. ;
  6. ;REVISION HISTORY:
  7. ;FEB-25-89, Original, based on BOOTA.68K, JUN-30-88.
  8. ;
  9. ;NOTES:
  10. ;This code resides in the first four blocks (1K) of the boot disk. The
  11. ; Amiga Kickstart boot reads the first 1K from the disk, verifies that
  12. ; it says "DOS", and then jumps to its execution entry point. This
  13. ; program then reads RESCOD.SYS from the disk, kills AmigaDOS, and then
  14. ; moves RESCOD.SYS into its proper places in memory and starts it.
  15. ; RESCOD.SYS, in turn, reads in SYSTEM.SYS (APEX.XPL) and starts it.
  16. ;
  17. ;This boot code is installed onto a newly formatted disk as follows:
  18. ;
  19. ; LOAD BOOTA2
  20. ;    CHANGE DEFAULTS (Y/N)? N
  21. ;    (Press RETURN to execute the checksum calculation)
  22. ;
  23. ; (Make sure unit is not in a sub-directory)
  24. ; WRITE
  25. ;    UNIT? 0
  26. ;    BLOCK? 0
  27. ;    BUFFER? $8000            (= BODY)
  28. ;    SIZE (BLOCKS)? 4
  29. ;
  30. ;
  31. ;    DISK BLOCK        CONTENTS
  32. ;    0-3        BOOTA2 (clobbers extended directory)
  33. ;    4-8        unused (extended backup directory)
  34. ;    9-12        directory
  35. ;    13-16        backup directory
  36. ;    17-96        RESCOD.SYS
  37. ;    97-3519        file space
  38. ;
  39. ;
  40. ;DATA STRUCTURES:
  41. ;
  42. ;  IOStdReq:
  43. ;  0    Message:0    Node:    0    *lnSucc
  44. ;  4        4        4    *lnPred
  45. ;  8        8        8    lnType
  46. ;  9        9        9    lnPri
  47. ;  10        10        10    *lnName        "APEX."
  48. ;  
  49. ;  14        14    *mnReplyPort    pointer to MsgPort
  50. ;  18        18    mnLength
  51. ;  
  52. ;  20    *ioDevice
  53. ;  24    *ioUnit
  54. ;  28    ioCommand        Clear/Change No./Read
  55. ;  30    ioFlags
  56. ;  31    ioError
  57. ;  32    ioActual        No. of bytes actually read
  58. ;  36    ioLength        No. of bytes to read
  59. ;  40    ioData            Pointer to buffer to read into
  60. ;  44    ioOffset        No. of bytes to start of data on disk
  61. ;  
  62. ;  msgPort:            Used for replies from trackdisk.device
  63. ;  0    Node:    0    *lnSucc
  64. ;  4        4    *lnPred
  65. ;  8        8    lnType
  66. ;  9        9    lnPri
  67. ;  10        10    *lnName        "APEX."
  68. ;  
  69. ;  14    mpFlags        Flags in message port
  70. ;  15    mpSigBit    Signal from AllocSignal
  71. ;  16    *mpSigTask    Pointer to the current task, from FindTask
  72. ;  
  73. ;  20    List:    0   mlHead    Points to mpTail
  74. ;  24        4   mlTail    Zero
  75. ;  28        8   mlTailPred    Points to mlHead
  76. ;
  77. ;----------------------------------------------------------------------
  78.  
  79. ;MEMTOP    EQU    $100000        ;Highest memory address +1
  80. MEMTOP    EQU    $80000        ;Highest memory address +1 *** DEBUG ***
  81. VSTART    EQU    $0400        ;Start location for RESCOD
  82. VRENTR    EQU    $7B4        ;Apex re-entry vector
  83. RAM    EQU    $40000        ;Absolute RAM location for AmigaDOS to
  84.                 ; load RESCOD.SYS into
  85. RESSIZE    EQU    $5000+$200    ;Total number of bytes in RESCOD.SYS
  86.                 ; including two half-sectors on each end
  87.                 ; (This must be a multiple of 512)
  88. IOStdReq EQU    RAM+RESSIZE    ;Offset into RAM to I/O request block
  89. msgPort    EQU    IOStdReq+48    ;Offset to the reply message port
  90.  
  91. ;Offsets into IOStdReq:
  92. ioCommand    EQU    28
  93. ioLength    EQU    36
  94. ioData        EQU    40
  95. ioOffset    EQU    44
  96.  
  97. ExecBase    EQU    4    ;Jump table for ROM-based exec routines
  98. ;Offsets into jump table for selected exec routines:
  99. DoIO        EQU    -$1C8
  100. OpenDevice    EQU    -$1BC
  101. AllocSignal    EQU    -$14A
  102. FindTask    EQU    -$126
  103. AllocAbs    EQU    -$CC
  104. SuperState    EQU    -$96
  105.  
  106. CIAA    EQU    $BFE001        ;Base address of 8520-A chip
  107. ;Offsets to CIA registers:
  108. PRA    EQU    $0        ;Peripheral Data Register A
  109. DDRA    EQU    $200        ;Data Direction Register A
  110.  
  111. CHIPREG    EQU    $DFF000        ;Base address of chip registers
  112. ;Offsets to chip registers:
  113. DMACON    EQU    $96        ;DMA control
  114. INTENA    EQU    $9A        ;Interrupt enable bits
  115. INTREQ    EQU    $9C        ;Interrupt request bits
  116. BPLCON0    EQU    $100        ;Bit plane control register 0
  117. BPL1DAT    EQU    $110        ;Bit plane 1 data register
  118. COLOR00    EQU    $180        ;Color register 00
  119.  
  120. ;----------------------------------------------------------------------
  121. ;Kickstart loads this program (BOOTA2.68K) at an unknown address
  122. ; therefore this code must be relocatable.
  123. ;
  124.     ORG    $0400        ;The LOADer jumps here
  125.     JMP    DOCKSUM.L
  126.  
  127. BODY    EQU    $8000        ;An arbitrary location
  128.     ORG    BODY
  129.  
  130. ;Kickstart requires the following header information:
  131.     ASCII    "DOS"        ;ASCII identification of the disk
  132.     DC.B    0
  133. CKSUM    DC.L    0        ;Checksum of the "boot block" (1st 1K)
  134.     DC.L    880        ;Pointer to "root block" (unused)
  135.  
  136. ;Kickstart jumps to this location:
  137. START    BRA.S    BT00
  138.     ASCII    "Apex, V1.8, Copyright (c) Feb-25-89 "
  139.     ASCII    "Computer Applications"
  140.     DC.B    0
  141.  
  142. ;----------------------------------------------------------------------
  143. ;This routine calculates and sets the checksum for this program.
  144. ;
  145. DOCKSUM    LEA    BODY.L,A0    ;Point to beginning of this program
  146.     LEA    4(A0),A1    ;Point A1 to checksum entry
  147.     CLR.L    (A1)        ;Initialize checksum
  148.     MOVE.W    #$400/4-1,D1    ;Set loop counter for number of longs
  149.     MOVEQ    #$00,D0        ;Initialize accumulator
  150. CS10    ADD.L    (A0)+,D0    ;Add long word
  151.     BCC.S    CS20
  152.     ADDQ.L    #1,D0        ;End arround carry
  153. CS20    DBF    D1,CS10        ;Next long word
  154.     NOT.L    D0        ;Ones complement of checksum
  155.     MOVE.L    D0,(A1)        ;Save result
  156.     JMP    VRENTR        ;Re-enter Apex (reload it if necessary)
  157.  
  158. ;----------------------------------------------------------------------
  159. ;Allocate memory for RESCOD.SYS:
  160. BT00    MOVE.L    #RESSIZE+$100,D0 ;Bytes to allocate (+IOStdReq +msgPort)
  161.     LEA    RAM.L,A1    ;Absolute address to allocate
  162.     MOVEA.L    ExecBase,A6
  163.     JSR    AllocAbs(A6)    ;Call exec routine to allocate memory
  164.     TST.L    D0        ;Error?
  165.     BNE.S    BT10        ;Branch if not
  166.     MOVE.L    #$BADC0DE1,D0    ;Return error code to Kickstart
  167.     RTS            ;Guru error $30000001, BADC0DE1
  168.  
  169. BT10    MOVE.W    #256/4-1,D0    ;Zero IOStdReq block
  170.     LEA    IOStdReq.L,A0
  171. BT15    CLR.L    (A0)+
  172.     DBF    D0,BT15
  173.  
  174. ;Set up reply message port:
  175.     LEA    msgPort.L,A5    ;Point A5 to base of message port
  176.     MOVE.L    APXNAME-@-2(PC),10(A5)    ;Set lnName in node structure
  177.  
  178.     SUBA.L    A1,A1        ;Name = null
  179.     JSR    FindTask(A6)    ;Find current task FindTask(A1=0)
  180.     MOVE.L    D0,16(A5)
  181.  
  182.     LEA    20(A5),A0    ;Set mlHead to mlTail
  183.     MOVE.L    A0,(A0)
  184.     ADDQ.L    #4,(A0)
  185.     MOVE.L    A0,8(A0)    ;Set mlTailPred to mlHead
  186.  
  187.     MOVEQ    #-1,D0
  188.     JSR    AllocSig(A6)    ;AllocSig(D0=-1)
  189.     MOVE.B    D0,15(A5)
  190.     BPL.S    BT20        ;Branch if no error
  191.     RTS            ;Return error code for the Guru
  192.  
  193. APXNAME    ASCII    "APEX."
  194.     DC.B    0
  195.  
  196. ;Open disk drive:
  197. ;Set iORequest = start of allocated memory
  198. BT20    LEA    IOStdReq.L,A1    ;iORequest: Pointer to I/O request
  199.                 ; block to be initialized
  200.     MOVE.L    #msgPort,14(A1)    ;Set pointer to reply message port
  201.     MOVE.L    APXNAME-@-2(PC),10(A1)    ;Set lnName in node
  202.  
  203.     LEA    TDNAME-@-2(PC),A0    ;devName: Requested device name
  204.     MOVEQ    #0,D0        ;unitNumber: Unit number on device (DF0)
  205.     MOVEQ    #0,D1        ;Flags: additional info (if any)
  206.     JSR    OpenDevice(A6)
  207.     TST.L    D0        ;Error?
  208.     BEQ.S    BT30        ;Branch if no error
  209.     RTS            ;Return with error code
  210.  
  211. TDNAME    ASCII    "trackdisk.device"
  212.     DC.W    0        ;Terminator
  213.  
  214. ;Read in RESCOD.SYS:
  215. BT30    LEA    IOStdReq.L,A1    ;Pass pointer to I/O request block
  216.     MOVE.W    #$0002,ioCommand(A1)    ;Set command to read
  217.     MOVE.L    #RESSIZE,ioLength(A1)    ;Number of bytes to read
  218.     MOVE.L    #RAM,ioData(A1)    ;Pointer to data buffer
  219.     MOVE.L    #16/2*512,ioOffset(A1)    ;Offset on disk to RESCOD.SYS
  220.                     ; (must be a multiple of 512)
  221.     JSR    DoIO(A6)        ;Read disk blocks
  222.     TST.L    D0            ;Error?
  223.     BEQ.S    BT40            ;Branch if not
  224.     RTS                ;Return with error code
  225.  
  226. ;Kill AmigaDOS (Hurray!!!):
  227. BT40    JSR    SuperState(A6)    ;Go to supervisor mode
  228.     ORI    #$0700,SR    ;Disable interrupts
  229.     LEA    MEMTOP.L,SP    ;Set the stack to top of memory
  230.  
  231.     LEA    CIAA.L,A6    ;Initialize CIA chips
  232.     MOVE.B    #$03,DDRA(A6)    ;Set bits 0 & 1 as outputs
  233.     MOVE.B    #$02,PRA(A6)    ;Overlay = 0 (off), LED = dim
  234.  
  235.     LEA    CHIPREG.L,A6
  236.     MOVE.W    #$7FFF,D0    ;Disable all bits
  237.     MOVE.W    D0,INTENA(A6)    ;Clear all interrupt enable bits
  238.     MOVE.W    D0,INTREQ(A6)    ;Clear all interrupt requests
  239.     MOVE.W    D0,DMACON(A6)    ;Disable all DMA channels
  240.     MOVE.W    #$0200,BPLCON0(A6)    ;No bit planes, color enabled
  241.     MOVE.W    #$0000,BPL1DAT(A6)    ;Blank display
  242.     MOVE.W    #$0024,COLOR00(A6)    ;Set background color
  243.  
  244. ;Move low part of RESCOD into its correct location:
  245.     LEA    $100+RAM.L,A6    ;Set "from" address
  246.     LEA    $00000000,A5    ;Set "to" address
  247.     MOVE.W    #16*8,D0    ;Move 16 blocks ($0000 up to $1000)
  248.     BSR.S    MOVBLK        ;Go do it
  249.  
  250. ;Move high part of RESCOD into its correct location:
  251.     LEA    $1100+RAM.L,A6    ;Set "from" address
  252.     LEA    MEMTOP-$4000.L,A5    ;Set "to" address
  253.     MOVE.W    #63*8+4,D0    ;Move 63.5 blocks (-$4000 up to -$0080)
  254.     BSR.S    MOVBLK        ;Go do it
  255.  
  256. ;Initialize the rest of memory to zero:
  257.     MOVEQ    #0,D0
  258.     LEA    $1000,A6    ;Start at the end of the low part
  259. BT50    MOVE.L    D0,(A6)+    ;WARNING: amount must be a multiple of 4
  260.     CMPA.L    #MEMTOP-$4000,A6    ;Finish at the beginning of the
  261.     BGE.S    BT50            ; high part
  262.  
  263.     JMP    VSTART        ;Enter RESCOD
  264.  
  265. ;-----------------------------------------------------------------------
  266. ;Move D0*32 bytes from A6 to A5.
  267. ; Most registers are destroyed.
  268. ; Note unusual entry point.
  269. ;
  270. MOV10    MOVEM.L    (A6)+,A4/D1-D7    ;Read 32 bytes at A6
  271.     MOVEM.L    A4/D1-D7,(A5)    ;Write 32 bytes at A5
  272.     ADDA.L    #32,A5        ;(Post incrementing is not allowed)
  273. MOVBLK    DBF    D0,MOV10    ;Loop until done
  274.     RTS
  275.  
  276.  
  277. MAX    EQU    BODY +$400    ;Maximum load location +1 (1K)
  278.     DCB.B    MAX-@, 0    ;Fill the rest of boot block with zeros
  279.  
  280.     END
  281. 
  282.     RTS
  283.  
  284.  
  285. MAX    EQU    BODY +$400    ;Maximum load location +1 (1K)
  286.     DCB.B    MAX-@, 0    ;Fill the rest of boot block with zero